-- | Module:        Hexena.Internal.SelfOrganisingMaps
--   Stability:     Experimental
--   Portability:   Portable
--
--   Internal-Use module.  This module exports variables and functions that 
--   are considered not for public consumption.  As such with all internal-use 
--   modules.  The variables contained are considered to be in flux and may 
--   be changed at any time as the project unfolds.  Developers use contents
--   contained herein at your own risk.
module Hexena.Internal.SelfOrganisingMaps
  (calculateSOM) where

import Data.Map
import Data.Datamining.Clustering.Gsom

calculateSOM :: Inputs -> IO Clustering
calculateSOM inputs = do
  -- Create a lattice, for simplicities sake using the centered
  -- lattice.
  lattice <- newCentered $ length inputs
  -- this is defined in the module
  let defaultPhases = defaults
  resultLattice <- run defaultPhases lattice inputs
  myClustering <- clustering resultLattice
  -- print myClustering
  -- print $ assocs myClustering
  mapM_ (uncurry doPrint) $ toList myClustering
  return myClustering

doPrint :: Coordinates -> Cluster -> IO ()
doPrint x y = putStrLn $ ((show x) ++ "\n\t" ++ (show y))

-- Running GSOM

-- run :: Phases -> Lattice -> Inputs -> IO Lattice
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Since a complete run of the GSOM algorithm means running a number
-- of Phases this is usually the main function used. run phases
-- lattice inputs runs the GSOM algorithm by running the phases in the
-- order specified, each time making passes over inputs and using the
-- produced Lattice to as an argument to the next phase. The initial
-- Lattice, lattice may be constructed with the newRandom and the
-- newCentered functions.

-- type Phases = [Phase]
-- ...?

